package com.hongye.proprietary.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.hongye.proprietary.vo.HomeSpaceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.proprietary.entity.SpaceHomeEntity;
import com.hongye.proprietary.service.SpaceHomeService;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.R;



/**
 * 楼市圈表
 */
@RestController
@RequestMapping("proprietary/spacehome")
public class SpaceHomeController {
    @Autowired
    private SpaceHomeService spaceHomeService;


    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = spaceHomeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 楼市圈表
     */
    @RequestMapping("homecircle")
    public R homecircle(){

        List<HomeSpaceVo> list=spaceHomeService.homecircle();
        return R.ok().put("homecircle",list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{agentSpaceId}")
    public R info(@PathVariable("agentSpaceId") Integer agentSpaceId){
		SpaceHomeEntity spaceHome = spaceHomeService.getById(agentSpaceId);

        return R.ok().put("spaceHome", spaceHome);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SpaceHomeEntity spaceHome){
		spaceHomeService.save(spaceHome);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SpaceHomeEntity spaceHome){
		spaceHomeService.updateById(spaceHome);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] agentSpaceIds){
		spaceHomeService.removeByIds(Arrays.asList(agentSpaceIds));

        return R.ok();
    }

}
